<?php
/**
* 코드그룹 로직파일
* /admin/logic/system/codegrp.php
* 2010-02-23
* hamhaja <hamhaja1@nate.com>
*/
// check auth
include_once dirname(__FILE__) . '/../../inc.auth.php';

// class require
$App->class_require('Table.Codegrp');
$App->class_require('Table.Code');
$Codegrp	= new Codegrp(&$Db);
$Code		= new Code(&$Db);

if ($g_subjob == 'list')
{
	// get code group list
	$code_group_list = $Codegrp->get_list();
}
else if ($g_subjob == 'insert')
{
	// check method
	if (!$App->check_method(POST)) $Error->fail(NO_PERMIT_METHOD);

	// is code group?
	if ($Codegrp->check(array($_POST['cg_code']))) $Error->fail(IS_GROUP);

	// insert code group record
	if ($Codegrp->insert($_POST)) $App->reload();
	else $Error->fail(INSERT_FAIL);
}
else if ($g_subjob == 'update')
{
	// check method
	if (!$App->check_method(POST)) $Error->fail(NO_PERMIT_METHOD);

	// is data?
	if ($_POST['data'])
	{
		// update code group record
		foreach ($_POST['data'] as $v)
		{
			$Codegrp->update($v);
		}
		$App->reload();
		//include_once $_SERVER['DOCUMENT_ROOT'] . "/test/rec_reload.htm";
	}
	else $Error->fail(TRAN_DATA_EMPTY);
}
else if ($g_subjob == 'delete')
{
	// is code group record?
	if (!$Codegrp->check(array($_GET['id1']))) $Error->fail(NOT_FIND_DATA);

	// delete code group record
	if ($Codegrp->group_delete($_GET['id1'])) $App->reload();
	else $Error->fail(DELETE_FAIL);
}
?>